//###############
// FILE : AbsComparator.java
// WRITER : Yaron Dinur, yarondi, 200184992
// WRITER : Yuval Ran, yuvran21, 032513483
// EXERCISE : oop ex1 2011
// DESCRIPTION:
//Compares two files by their filename (with the full path)
//###############

package orders;

import java.io.File;
import java.io.IOException;
import java.util.Comparator;

public class AbsComparator implements Comparator<File> {
	
	// Compares the full path of the file (absolute name).
	public int compare(File file1, File file2){
		
		String path1 = null;
		String path2 = null;
		
		try {
			path1 = file1.getCanonicalPath();
			path2 = file2.getCanonicalPath();
		}
		catch (IOException e){
			try {
				throw new IOException();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			//System.err.println("Error");
			//System.exit(-1);
		}
		
		int result = (int) Math.signum(path1.compareTo(path2));
		return result;
	}

}